<template>
  <el-row>
    <el-table
        v-loading="loading"
        :data="tableData"
        style="width: 100%"
        :cell-style="{height:'.1vh',padding:'1px'}"
        :row-style="{height:'.1vh'}"
        :header-cell-style="{height:'.1vh',padding:'1px'}"
        :border="true"
    >
      <el-table-column
          label="收测时间"
          prop="time"
          width="160"
          align="center"
      >
      </el-table-column>

      <el-table-column
          label="收测人"
          prop="monitor"
          align="center"
      >
      </el-table-column>
    </el-table>
    <Pagination
        style="width: 100%"
        layout="total,pager,next"
        :total="total"
        @currentChange="currentChange"
    />
  </el-row>
</template>

<script>
// ------------------ axios ------------------
import {getRedioTest} from "../../../../../api/work";
// ------------------ element-ui ---------------------
import Pagination from "../../../../../components/element-ui/Pagination";

export default {
  components: {
    Pagination
  },
  data() {
    return {
      tableData: [],
      loading: false,
      //  --------- 分页相关 --------------
      total: 100,
    }
  },
  created() {
    const pd = {
      page: 1,
      limit: 10,
      mobile: this.mobile,
    }
    this.getRedioTest(pd);
  },
  watch: {
    mobile: function () {
      const pd = {
        page: 1,
        limit: 10,
        mobile: this.mobile,
      }
      this.getRedioTest(pd);
    }
  },
  methods: {
    // -------------- axios -----------------
    /**
     * 获取收测记录
     */
    getRedioTest: function (pd) {
      this.loading = true;
      getRedioTest(pd)
          .then(res => {
            this.loading = false;
            this.tableData = res.data.data;
            this.total = res.data.count;
          })
          .catch(err => {
            this.loading = false;
            console.error(err)
          });
    },

    // -------------- 功能 ---------------
    /**
     * 翻页
     * @param params
     */
    currentChange(params) {
      const pd = {
        page: params.currentPage,
        limit: params.pageSize,
        mobile: this.mobile
      }
      this.getRedioTest(pd);
    }
  },
  props: {
    mobile: {
      type: String,
      default: ""
    }
  }
}
</script>

<style scoped>

</style>